package net.mingsoft.flk.service.Impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.mingsoft.flk.entity.vo.FlkRole;
import net.mingsoft.flk.entity.vo.Role;
import net.mingsoft.flk.entity.vo.RoleModel;
import net.mingsoft.flk.mapper.RoleMapper;
import net.mingsoft.flk.service.RoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 角色表 服务实现类
 * </p>
 *
 * @author 作者
 * @since 2023-03-11
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {

    @Resource
    private RoleModelServiceImpl modelService;

    /**
     * 获取
     *
     * @param id 角色id
     * @return obj
     */
    @Override
    public FlkRole get(Integer id) {
        Role role = this.getById(id);
        QueryWrapper<RoleModel> wrapper = new QueryWrapper<>();
        wrapper.eq("role_id", id);
        List<RoleModel> list = modelService.list(wrapper);
        return new FlkRole()
                .setRoleBean(role).setRoleModel(list);
    }

}
